//
//  customCollectionViewItem.m
//  MacDevTest
//
//  Created by lbxia on 2020/8/16.
//  Copyright © 2020 com.lbx. All rights reserved.
//

#import "customCollectionViewItem.h"
#import "LBXTrackingAreasView.h"
#import "SWSTAnswerButton.h"
@interface customCollectionViewItem ()<LBXTrackingAreasViewDelegate>
@property (weak) IBOutlet SWSTAnswerButton *clostBtn;
@property (weak) IBOutlet NSImageView *userImageView;
@property (weak) IBOutlet NSTextField *userNickName;

@end

@implementation customCollectionViewItem

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do view setup here.
    
    self.view.wantsLayer = YES;
    
    LBXTrackingAreasView *tView = (LBXTrackingAreasView*)self.view;
    tView.delegate = self;
    
    _clostBtn.hidden = YES;
    
    _clostBtn.normalImage = [NSImage imageNamed:@"AIO_Tab_Close_Normal"];
    _clostBtn.hoverImage = [NSImage imageNamed:@"AIO_Tab_Close_Hover"];
    _clostBtn.highlightImage = [NSImage imageNamed:@"AIO_Tab_Close_Down"];
    
    
    _userImageView.imageScaling = NSImageScaleProportionallyDown;
    _userImageView.wantsLayer = YES;
    //宽度的一半(宽和高相等)即能达到圆形效果
    _userImageView.layer.cornerRadius = 21;
    _userImageView.layer.backgroundColor = [NSColor whiteColor].CGColor;
          
}

- (void)setSelected:(BOOL)selected
{
    [super setSelected:selected];
    
    self.view.layer.backgroundColor = selected ? [NSColor colorWithRed:0.92 green:0.92 blue:0.92 alpha:1].CGColor : [NSColor whiteColor].CGColor;
}

- (void)mouseEnteredEventWithView:(LBXTrackingAreasView*)view
{
    _clostBtn.hidden = NO;
}
- (void)mouseExitedEventWithView:(LBXTrackingAreasView*)view
{
    _clostBtn.hidden = YES;
}

@end
